<template>
	<div>
		<el-form ref="form" :rules="rules" :model="form" label-width="120px">


			<el-form-item label="客户姓名" prop="name">
				<el-input v-model="form.name"></el-input>
			</el-form-item>
			<el-form-item label="性别" prop="sex">
				<el-input v-model="form.sex"></el-input>
			</el-form-item>
			<el-form-item label="家属姓名" prop="relaName">
				<el-input v-model="form.relaName"></el-input>
			</el-form-item>

			<el-form-item label="家属电话" prop="relaTel">
				<el-input v-model="form.relaTel"></el-input>
			</el-form-item>

			<el-form-item label="事项" prop="event">
				<el-input v-model="form.event"></el-input>
			</el-form-item>

				
				<el-form-item label="时间" prop="time">
						<span class="demonstration"></span>
						    <el-date-picker
						      v-model="form.time "
						      type="date"
							  value-format="yyyy-MM-dd"
						      placeholder="选择日期">时间
						    </el-date-picker>
						
					</el-form-item>
		
			
		
			<el-form-item label="地点" prop="place">
				<el-input v-model="form.place"></el-input>
			</el-form-item>
			<el-form-item label="发现人" prop="finding">
				<el-input v-model="form.finding"></el-input>
			</el-form-item>
			<el-form-item label="处置结果" prop="disposalResult">
				<el-input v-model="form.disposalResult"></el-input>
			</el-form-item>
			<el-form-item label="是否通知" prop="notice">
				<el-input v-model="form.notice"></el-input>
			</el-form-item>
			<el-form-item label="备注" prop="comment">
				<el-input v-model="form.comment"></el-input>
			</el-form-item>
			<el-form-item label="通知人" prop="notifier">
				<el-input v-model="form.notifier"></el-input>
			</el-form-item>
			
				<el-form-item label="通知时间" prop="noticeTime">
						<span class="demonstration"></span>
						    <el-date-picker
						      v-model="form.noticeTime "
						      type="date"
							  value-format="yyyy-MM-dd"
						      placeholder="选择日期">时间
						    </el-date-picker>

			</el-form-item>
			<el-form-item>
				<el-button type="primary" plain @click="save">保存数据</el-button>

			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	export default {
		name: 'HandleEmerg',
		components: {

		},
		props: [
			'show',
			'editid'
		],
		data() {
			return {
				form: {
					name: '',
					sex: '',
					relaName: '',
					relaTel: '',
					event: '',
					time: '',
					place: '',
					finding: '',
					disposalResult: '',
					notice: '',
					comment: '',
					notifier: '',
					noticeTime: '',
				},
				rules: {

					name: [{
							required: true,
							message: '类别名不能为空',
							trigger: 'blur'
						},
						{
							min: 1,
							max: 100,
							message: '长度在 1 到 100 个字符',
							trigger: 'blur'
						}
					],
					relaTel: [{
						required: true,
						message: '请输入联系电话',
						trigger: 'blur'
					}, {
						min: 11,
						max: 11,
						message: '手机号为11位有效',
						trigger: 'blur'
					}],
				},

				handle_emerg: [],
				depts: [],
			}
		},
		created() {
			if (this.editid) {
				this.show = true;
				this.$axios.get(
					'handleEmerg/getById',
					response => {
						this.form = response.obj
						
					}, 
					{id: this.editid })
			}
		},
		methods: {
			save() {
				this.axios.get('/handleEmerg/add', (data) => {
					if (data) {
						this.$emit('update:show', false)
						this.$emit('getData')
					}

				}, this.form, '保存成功');
			},
			update() {
				this.axios.get('/handleEmerg/update', (data) => {
					if (data) {
						this.$emit('update:show', false)
						this.$emit('getData')
					}
			
				}, this.form, '更新成功');
			}
		}



	}
</script>

<style>
</style>
